#pragma once
#include <netinet/in.h>
#include "Channel.h"
#include "XnccType.h"
namespace xncc {
namespace foundation {
    class DatagramSocketChannel final : public Channel
    {
      public:
        DatagramSocketChannel(EventLoop* loop, int sock_fd, types::connection_id_t connId);
        ~DatagramSocketChannel() override;

        DatagramSocketChannel(const DatagramSocketChannel&)             = delete;
        DatagramSocketChannel(const DatagramSocketChannel&&)            = delete;
        DatagramSocketChannel& operator=(const DatagramSocketChannel&)  = delete;
        DatagramSocketChannel& operator=(const DatagramSocketChannel&&) = delete;

        auto Type() -> ChannelType::value override { return ChannelType::DGRAM_CHANNEL; }
        void handleRead() override;
        void handleWrite() override;
        void handleError(const std::string& reason) override;
        void sendMsg(const char* msg, size_t len);

      private:  // 列表初始化
        const uint32_t HEADER_LEN;
    };
}  // namespace foundation
}  // namespace xncc